import { Modal, ModalConfig, ModalMethod } from "@arco-design/web-vue";

type UseModalNoticeReturn = Record<keyof Omit<ModalMethod, "open">, (config: ModalConfig) => void>;

export default function useModalNotice(): UseModalNoticeReturn {
  const methods: any = {};
  const config: Partial<ModalConfig> = {
    width: 540,
  };

  for (const name of ["confirm", "info", "success", "warning", "error"]) {
    methods[name] = (customConfig: ModalConfig) => {
      Modal[name]({
        ...config,
        ...customConfig,
      });
    };
  }

  return methods as UseModalNoticeReturn;
}
